package com.powernode.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.powernode.domain.SysLog;
import com.powernode.mapper.SysLogMapper;
import com.powernode.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;

/**
 * 内容:
 * 作者: cy
 */
@Service
public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> implements SysLogService {

    @Autowired
    private SysLogMapper sysLogMapper;

    /**
     * 分页查询操作日志
     *
     * @param page
     * @param sysLog
     * @return
     */
    @Override
    public Page<SysLog> selectSysLogPage(Page<SysLog> page, SysLog sysLog) {
        return sysLogMapper.selectPage(page, new LambdaQueryWrapper<SysLog>()
                .eq(!ObjectUtils.isEmpty(sysLog.getUserId()), SysLog::getUserId, sysLog.getUserId())
                .like(StringUtils.hasText(sysLog.getOperation()), SysLog::getOperation, sysLog.getOperation())
                .orderByDesc(SysLog::getCreateDate)
        );



    }
}
